package com.wcsy.myblog.controller;

import io.swagger.annotations.Api;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * index
 */
@Controller
@CrossOrigin
@Api(description = "index")
public class PageController {

    @GetMapping("/login")  //登陆页面
    public String login(){
        return "login";
    }

    @GetMapping({"/","/index"})  //首页
    public String index(){
        return "index";
    }
    /**
     * @apiNote 注销
     * */
    @RequestMapping("/logout")
    public String logout(){
        Subject subject = SecurityUtils.getSubject();
        subject.logout();
        return "redirect:/login";
    }
    /**
     * @apiNote 注册
     * */
    @RequestMapping("/register")
    public String register(){
        return "register";
    }
    @RequestMapping("/hello")
    public String hello(){
        return "helloworld";
    }


}
